using Gateway.IApplication.BaseInput;
using Gateway.IApplication.WorkFlow;
using Gateway.IApplication.WorkFlow.Input;
using Gateway.IQuery;
using Gateway.IQuery.WorkFlow;
using Gateway.IQuery.WorkFlow.Request;
using Gateway.IQuery.WorkFlow.Result;

namespace Gateway.UI.Api.Controllers;

/// <summary>
/// 工作流 服务
/// </summary>
public class WorkFlowController : BaseController
{
     private readonly IWorkFlowApp _app;
    private readonly IWorkFlowQuery _query;

    /// <summary>
    /// 
    /// </summary>
    public WorkFlowController(IWorkFlowApp app, IWorkFlowQuery query)
    {
        _app = app;
        _query = query;
    }

    /// <summary>
    /// 创建
    /// </summary>
    /// <param name="input"></param>
    /// <returns>返回主键标识</returns>
    [HttpPost, Route("add")]
    public async Task<bool> Add(CreateWorkFlowInput input)
    {
        return await _app.Add(input);
    }

    /// <summary>
    /// 更新
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("update")]
    public async Task<bool> Update(UpdateWorkFlowInput input)
    {
        return await _app.Update(input);
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("remove")]
    public async Task<bool> Remove(RemoveInput input)
    {
        return await _app.Remove(input);
    }

    /// <summary>
    /// 禁用/启用
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    [HttpPost, Route("disable")]
    public async Task<bool> Disable(DisableInput input)
    {
        return await _app.Disable(input);
    }
    /// <summary>
    /// 获取详情
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet, Route("detail/{id}")]
    public async Task<WorkFlowDetailResult> GetDetail(string id)
    {
        return await _query.GetDetail(id);
    }

    /// <summary>
    /// 项目分页列表
    /// </summary>
    /// <returns></returns>
    [HttpPost, Route("list/page")]
    public async Task<PageResult<WorkFlowListResult>> GetPageList(WorkFlowPageListRequest request)
    {
        return await _query.GetList(request);
    }
}